﻿@model DataMongo.Entities.Group
@{
    ViewBag.Title = "CreateGroup";
    Layout = "~/Views/Shared/_LayoutProfile.cshtml";
    var list = ViewBag.FriendList as SelectList;
    var check = ViewBag.Selected as List<string>;
   

}



<div class="row-fluid">
    <div class="span12">
        <div class="box box-bordered">
            <div class="box-title">
                <h3><i class="icon-th-list"></i> Group Edit (@Model.GroupName)</h3>
            </div>
            <div class="box-content nopadding">
                @using (Html.BeginForm("EditGroup", "Group", FormMethod.Post, new { @class = "form-horizontal form-striped" }))
                {
                    @Html.HiddenFor(x=>x.GroupId)

                    <div class="control-group">
                        <label for="textfield" class="control-label">Group Name</label>
                        <div class="controls">
                            @Html.TextBoxFor(x => x.GroupName, new { @class = "input-xlarge", @placeholder = "Group Name" })
                        </div>
                    </div>

                    <div class="control-group">
                        <label for="textfield" class="control-label">Members</label>
                        <div class="controls">
                            @*@Html.ListBox("FriendList", list, new { @class = "input-xlarge", @placeholder = "Text input" })*@

                            <select name="member" multiple="multiple" class="input-xlarge" placeholder="Text input">
                                @foreach (var item in list)
                                {
                                    var selected = "";

                                   
                                    if (item.Text == WebSecurity.CurrentUserId.ToString())
                                    {
                                        if (check.Contains(item.Value))
                                        {
                                            selected = "selected";
                                        }

                                        <option @selected value="@item.Value">@MVCMongo.Services.UtilityService.GetCurrentUserFullName(Convert.ToInt32(item.Value))</option>

                                    }
                                    else
                                    {
                                        if (check.Contains(item.Text))
                                        {
                                            selected = "selected";
                                        }

                                        <option @selected value="@item.Text">@MVCMongo.Services.UtilityService.GetCurrentUserFullName(Convert.ToInt32(item.Text))</option>

                                    }
                                }

                            </select>
                        </div>
                    </div>

                    <div class="control-group">
                        <label for="textfield" class="control-label">Privacy</label>
                        <div class="controls">
                            @Html.RadioButtonFor(x => x.Type, "open", new { @class = "input-xlarge", @placeholder = "Text input" })Open
                        </div>
                        <div class="controls">
                            @Html.RadioButtonFor(x => x.Type, "close", new { @class = "input-xlarge", @placeholder = "Text input" })Close
                        </div>
                        <div class="controls">
                            @Html.RadioButtonFor(x => x.Type, "private", new { @class = "input-xlarge", @placeholder = "Text input" })Private
                        </div>
                    </div>
                    <div class="form-actions">
                        <button type="submit" class="btn btn-primary">Save changes</button>
                        <button type="button" class="btn">Cancel</button>
                    </div>
                }
            </div>
        </div>
    </div>
</div>
